<?php

require_once BaseUtil::getModulePath("base")  .  '/forms/BaseForm.php';
require_once BaseUtil::getModulePath("promotion")  .  '/constants/PromotionConstant.php';

class CouponPubForm extends BaseForm {

	public function __construct ()
	{
		parent::__construct();
		//		$this->setAction(HttpUtil::getUrl("promotion", "subproductcoupon"));

		// name
		$name = new Zend_Form_Element_Text('name');
		$name->setLabel($this->translate->_('pname'));
		$name->addFilter("StringTrim");
		$name->setRequired(true);
			

		//show_in_product
		$depChkbox = new Zend_Form_Element_Select("show_in_product");
		$depChkbox->setLabel($this->translate->_('show_in_product'));
		$depChkbox->setRequired(true);
		$depChkbox->setMultiOptions(array(1=>$this->translate->_('yesLabel'),0=>$this->translate->_('noLabel')));
		$depChkbox->setAttrib("onchange", "javascript:Promotion.changeShowProduct();");

		// short_description
		$short_description = new Zend_Form_Element_Textarea('short_description');
		$short_description->setLabel($this->translate->_('short_description'));
		$short_description->setAttribs(array("rows" => 5, "cols" => 40));
		$short_description->addFilter("StringTrim");
		$short_description->setRequired(false);

		// long_description
		$long_description = new Zend_Form_Element_Textarea('long_description');
		$long_description->setLabel($this->translate->_('long_description'));
		$long_description->setAttribs(array("rows" => 5, "cols" => 40));
		$long_description->addFilter("StringTrim");
		$long_description->setRequired(true);

		//code
		/*$code = new Zend_Form_Element_Text('code');
		$code->setLabel($this->translate->_('code'));
		$code->addFilter("StringTrim");
		$code->setRequired(true);
*/
		//from
		$from = new Zend_Form_Element_Text('from');
		$from->setLabel($this->translate->_('from'));
		$from->addFilter("StringTrim");
		$from->setRequired(true);

		//to
		$to = new Zend_Form_Element_Text('to');
		$to->setLabel($this->translate->_('to'));
		$to->addFilter("StringTrim");
		$to->setRequired(true);

		//priority
		//		$priority = new Zend_Form_Element_Text('priority');
		//		$priority->setLabel($this->translate->_('priority'));
		//		$priority->addFilter("StringTrim");
		//		$priority->setRequired(true);

		//status
		$status = new Zend_Form_Element_Select("status");
		$status->setLabel($this->translate->_('promotionStatus'));
		$status->setRequired(true);
		$status->setMultiOptions(array(1=>$this->translate->_('statusA'),0=>$this->translate->_('statusI')));
		
		//auto reply
		$autoReply = new Zend_Form_Element_Select("auto_apply");
		$autoReply->setLabel($this->translate->_('autoApply'));
		$autoReply->setRequired(true);
		$autoReply->setMultiOptions(array(0=>$this->translate->_('noLabel'),1=>$this->translate->_('yesLabel')));

		//total uses
		$uses = new Zend_Form_Element_Text('uses');
		$uses->setLabel($this->translate->_('totalUses'));
		$uses->addFilter("StringTrim");
		$uses->setRequired(true);
        $uses->setAttrib('id','uses');
        $uses->setAttrib("onblur","javascript:Promotion.validInteger($(this).val(),'uses')");
		//customer
		//		$customer = new Zend_Form_Element_Text('customer');
		//		$customer->setLabel($this->translate->_('customer'));
		//		$customer->addFilter("StringTrim");
		//		$customer->setRequired(true);


		//stackable
		$stackable = new Zend_Form_Element_Select("stackable");
		$stackable->setLabel($this->translate->_('stackable'));
		$stackable->setRequired(true);
		$stackable->setMultiOptions(array(1=>$this->translate->_('yesLabel'),0=>$this->translate->_('noLabel')));
		
		$priority = new Zend_Form_Element_Text('priority');
        $priority->setLabel($this->translate->_("priority"));
        $priority->addFilter("StringTrim");
        $priority->setAttrib('id','priority');
        $priority->setAttrib("onblur","javascript:Promotion.validInteger($(this).val(),'priority')");
		

		$usesPerCustomer = new Zend_Form_Element_Text('uses_per_customer');
		$usesPerCustomer->setLabel($this->translate->_('usesPerCustomer'));
		$usesPerCustomer->setRequired(true);
		$usesPerCustomer->setAttrib('id','uses_per_customer');
		$usesPerCustomer->setAttrib("onblur","javascript:Promotion.validInteger($(this).val(),'uses_per_customer')");
		
		$exhaustPoint = new Zend_Form_Element_Text('exhaust_point');
        $exhaustPoint->setLabel($this->translate->_("exhaustPoint"));
        $exhaustPoint->addFilter("StringTrim");
        $exhaustPoint->setAttrib('id','exhaust_point');
        $exhaustPoint->setAttrib("onblur","javascript:Promotion.validInteger($(this).val(),'exhaust_point')");
       // $exhaustPoint->setRequired(true);
       
        
        $minACPoint = new Zend_Form_Element_Text('min_ac_point');
        $minACPoint->setLabel($this->translate->_("minACPoint"));
        $minACPoint->addFilter("StringTrim");
        $minACPoint->setAttrib('id','min_ac_point');
        $minACPoint->setAttrib("onblur","javascript:Promotion.validInteger($(this).val(),'min_ac_point')");
       // $minACPoint->setRequired(true);
       
        $startDate = new Zend_Form_Element_Text('start_date');
		$startDate->setLabel($this->translate->_('startDate'));
		$startDate->addFilter("StringTrim");
		$startDate->setAttrib('id','start_date');
		//$startDate->setAttrib("onblur","javascript:Promotion.validEmpty($(this).val(),'start_date')");
		//$startDate->setRequired(true);
	   

		
		$endDate = new Zend_Form_Element_Text('end_date');
		$endDate->setLabel($this->translate->_('endDate'));
		$endDate->addFilter("StringTrim");
		$endDate->setAttrib('id','end_date');
		//$endDate->setAttrib("onblur","javascript:Promotion.validEmpty($(this).val(),'end_date')");
		//$endDate->setRequired(true);
		
		
       
		
		$this->addElements(array($name,$depChkbox,$short_description,$long_description,$from,$to,$status,$autoReply,
		                        $usesPerCustomer,$uses,$stackable,$priority,$exhaustPoint,$minACPoint,$startDate,$endDate));


		$this->setElementDecorators(array(
		'ViewHelper',
		array(array('div' => 'HtmlTag'), array('tag' => 'div',"class" => "form_element")),
		));

	}
}
